﻿


<div ms-controller="tempview">
    <!--<div class="sui-form form-inline">
        <a class="sui-btn btn-large btn-primary" style="margin-left:10px;" ms-click="GetLIST()">刷新楼层</a>
        <a style="margin-left:10px;" class="sui-btn btn-large btn-success" ms-click="ADDLAYC('')">添加楼层</a>
    </div>-->
    <div class="sui-layout">
        <div class="sidebar">
            <p style="border-bottom: 2px solid #28a3ef;padding-bottom:10px;margin-top:0">所有楼层</p>
            <ul id="treeDemo" class="ztree"></ul>
        </div>
        <div class="content">

            <!--<p style="border-bottom: 2px solid #28a3ef;padding-bottom:10px;">通道数据</p>-->
            <ul class="sui-nav nav-tabs nav-large nav-primary" style="height: 28px;padding-bottom:0px;margin-bottom:5px;">
                <li ms-repeat-el="PathList" ms-class="active:PID==el.ID" ms-click="GetEqu(el.ID)"><a>{{el.PathName}}</a></li>
            </ul>
            <p style="text-align:right;padding:0;margin:0;">
                <label class="checkbox-pretty inline" style="color:red;font-size:14px;" id="lbshowerr" >
                    <input type="checkbox" ms-click="SelErrflag()"><span >报警信息</span>
                </label>
            </p>
            
            <table class="sui-table table-primary table-zebra">
                <thead>
                    <tr>
                        <th>通道名称</th>
                        <th>通道类型</th>
                        <th>值</th>
                        <th>状态</th>
                        <th>检测时间</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ms-repeat-el="ListData2" ms-class="red:(el.PathStatus!='正常'&&el.PathStatus!='通道初始化')" >
                        <td>{{el.PathName}}</td>
                        <td>{{el.PathType}}</td>
                        <td>{{el.PathValue}}</td>
                        <td>{{el.PathStatus}}</td>
                        <td>{{el.CRTime}}</td>
                    </tr>

                </tbody>
            </table>
            <div id="pageDiv"></div>

            </div>
            

    </div>
</div>

<script type="text/javascript">

    var treeObj;
    var tempmodel = avalon.define({
        $id: "tempview",
        search: { key: "" },
        page: { pageindex: 1, pagecount: 15 },
        modelData: {},
        modelData2: {},
        ShowColumns: [],
        ListData: [],
        PathList:[],
        ListData2:[],
        APINAME: "",
        Operation: "",
        IsLayc: true,
        LYID: "",
        PID: "",
        errflag: "",
        old: ComFunJS.getQueryString("old"),
        GetLIST: function () {

            ComFunJS.getJSON("BASE_GETLAYCTREE", function (r) {
                if (r.error == "") {
                    tempmodel.ListData = r.result;

                    var setting = {
                        callback: {
                            onClick: zTreeOnClick
                        }
                    };
                    var zNodes = eval("(" + JSON.stringify(r.result) + ")");

                    treeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);

                    var nodes = treeObj.getNodes();
                    if (nodes.length > 0) {
                        treeObj.expandNode(nodes[0], true, false);
                        var children1 = nodes[0].children[0];
                        if (children1) {
                            treeObj.selectNode(children1);

                            tempmodel.LYID = tempmodel.ListData[0].children[0].ID;
                            tempmodel.GetPath();
                        }
                    }

                }
            })
        },
        SelErrflag: function () {
            if ($("#lbshowerr").hasClass("checked")) {
                tempmodel.errflag = "";
            } else {
                tempmodel.errflag = "1";
            }
            tempmodel.GetEqu();
        },
        GetEqu: function (ID) {
            if (ID) {
                tempmodel.PID = ID;
            }
            tempmodel.ListData2.clear();            

            ComFunJS.getJSON("BASE_GETPATHDATALIST", { P1: tempmodel.LYID, P2: tempmodel.PID, pageindex: tempmodel.page.pageindex, pagecount: tempmodel.page.pagecount, errflag: tempmodel.errflag, old: tempmodel.old }, function (r) {
                if (r.error == "") {
                    tempmodel.ListData2 = r.result;

                    $("#pageDiv").pagination({  //分页容器
                        styleClass: ['sui-pagination'],  //分页样式
                        //showCtrl: false,
                        displayPage: 6,
                        itemsCount: r.total,
                        pageSize: tempmodel.page.pagecount,
                        onSelect: function (num) {
                            tempmodel.page.pageindex = num;
                            ComFunJS.getJSON("BASE_GETPATHDATALIST", { P1: tempmodel.LYID, P2: tempmodel.PID, pageindex: tempmodel.page.pageindex, pagecount: tempmodel.page.pagecount, errflag: tempmodel.errflag, old: tempmodel.old }, function (r) {
                                tempmodel.ListData2.clear();
                                tempmodel.ListData2 = r.result;
                            })
                        }
                    })

                    $('#pageDiv').pagination('updateItemsCount', r.total, 1);
                }

            })
        },
        GetPath: function () {
            tempmodel.PathList.clear();
            tempmodel.ListData2.clear();
            ComFunJS.getJSON("BASE_GETPATHLIST", { P1: tempmodel.LYID }, function (r) {
                if (r.error == "") {
                    tempmodel.PathList = r.result;
                    if (r.result && r.result.length>0) {
                        tempmodel.GetEqu(r.result[0].ID);
                    }
                }
            });
            
        }
    })
    avalon.ready(function () {
        //tempmodel.GetPath();
        tempmodel.GetLIST();
        //$(".sidebar").height(window.outerHeight - 100);
    })

    function zTreeOnClick(event, treeId, treeNode) {
        if (treeNode.lvl == "1") {
            //tempmodel.LYID = treeNode.ID;
            //tempmodel.PID = "";

        } else if(treeNode.lvl=="2") {
            tempmodel.LYID = treeNode.ID;
            tempmodel.GetPath();
        }
        
        //tempmodel.GetEqu();
        //tempmodel.GetEqu(treeNode.ID, treeNode.lvl);

    };

    //# sourceURL=layc.js
</script>
